﻿<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width,initial-scale=1.0">
    <title>Document</title>
    <link rel="stylesheet" href="index.css">
</head>
<body>
    <div id="app">
        <table v-if="goods.length > 0">
            <thead>
                <th>序号</th>
                <th>名称</th>
                <th>价格</th>
                <th>数量</th>
                <th>操作</th>
            </thead>
            <tbody>
                <tr :class="{active: show === index}" @mouseover="active(index)" v-for="(item, index) in goods">
                    <td>{{item.id}}</td>
                    <td>{{item.name}}</td>
                    <td>{{item.price | showPrice}}</td>
                    <td>
                        <button @click="add(item)" :disabled="item.num == 1 ? true : false">-</button>
                        <span>{{item.num}}</span>
                        <button @click="sub(item)">+</button>
                    </td>
                    <td><button @click="del(index)">删除</button></td>
                </tr>
            </tbody>
        </table>
        <h2 v-else="goods.length > 0">购物车已经清空!</h2>
        <h2>商品总价{{totalPrice | showPrice}}</h2>
    </div>
    <script src="vue.js"></script>
    <script src="index.js"></script>
</body>
</html>